<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // var xhr = new XMLHttpRequest();

        // xhr.open('post', 'http://www.liulongbin.top:3006/api/addbook');

        // // 设置请求体
        // xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');

        // xhr.send("bookname=雪中悍刀行&author=烽火戏诸侯&publisher=黑马程序员");

        // xhr.onreadystatechange = function() {
        //     if (xhr.readyState === 4 && xhr.status === 200) {
        //         console.log(xhr.responseText)
        //     }
        // }
        var xhr = new XMLHttpRequest()

        xhr.open('post', 'http://www.liulongbin.top:3006/api/addbook')

        xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded')

        xhr.send('bookname=雪中悍刀行&author=烽火戏诸侯&publisher=黑马程序员')

        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                console.log(xhr.responseText)
            }
        }
    </script>
</body>

</html>